package com.example.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: 21050134
 * @date: 2023/12/11 14:23
 * @description:
 */
public class MyHttpServletRequestWrapper extends HttpServletRequestWrapper {

	private final Map<String, String[]> parameterMap;

	/**
	 * @param request
	 */
	public MyHttpServletRequestWrapper(HttpServletRequest request) {
		super(request);
		parameterMap = new HashMap<>(request.getParameterMap());
	}

	@Override
	public String[] getParameterValues(String name) {
		String[] values = parameterMap.get(name);
		if (values == null) {
			values = super.getParameterValues(name);
		}
		return values;
	}

	public void setParameter(String name,  String ...value) {
		parameterMap.put(name, value);
	}
}
